<template>
  <div class="detail-info" v-if="Object.keys(detailInfo).length !== 0">
    <div class="info-desc">
      <div class="start"></div>
      <div class="main">{{detailInfo.desc}}</div>
      <div class="end"></div>
    </div>
    <div class="info-show">
      <p class="info-show-title">{{detailInfo.detailImage[0].key}}</p>
      <div class="info-show-main">
        <img v-for="(item, index) in detailInfo.detailImage[0].list" :key="index" :src="item" alt="" @load="imgLoad">
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'DetailGoodsInfo',
  props: {
    detailInfo: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      counter: 0,
      imagesLength: 0
    }
  },
  methods: {
    imgLoad() {
      if (++this.counter === this.imagesLength) {
        this.$emit('imgLoad')
      }
    }
  },
  watch: {
    detailInfo() {
      this.imagesLength = this.detailInfo.detailImage[0].list.length
    }
  }
}
</script>
<style scoped>
  .info-desc {
    position: relative;
    padding: 15px;
  }
  .info-desc .main{
    text-indent: 2em;
    font-size: 15px;
    line-height: 1.4;
  }
  .info-desc .start ,
  .info-desc .end {
    position: relative;
    width: 100px;
    border-bottom: 2px solid #ccc;
    margin: 5px 0;
  }
  .info-desc .end {
    position: absolute;
    right: 15px;
  }
  .info-desc .start::before ,
  .info-desc .end::before {
    display: inline-block;
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    top: -3px;
    background-color: #000;
  }
  .info-desc .start::before {
    left: 0;
  }
  .info-desc .end::before {
    right: 0;
  }
  .info-show .info-show-title {
    padding: 0 15px;
    color: #000;
  }
  .info-show .info-show-main img {
    width: 100%;
  }
</style>